<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>runner detail</title>
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all">
    <script src="../../js/common.js"></script>
    <style>
        body {
            height: 100%;
            width: 100%;
        }

        .image_style {
            height: 200px;
            width: 30%;
            margin-right: 1%;
            margin-left: 1%;
            float: left;
            border-color: aqua;
            border-style: solid;
            border-width: 1px;
        }

        .bn {
            margin-top: 220px;
            text-align: center;
        }

        .head {
            height: 50px;
        }
    </style>
</head>

<body>
    <div class="main">
        <div class="head">
        </div>
        <div>
            <div class="image_b">
                <img class="image_style" id="img" src="" alt="">
            </div>
            <div class="image_b">
                <img class="image_style" id="img1" src="" alt="">
            </div>
            <div class="image_b">
                <img class="image_style" id="img2" src="" alt="">
            </div>
        </div>
        <form class="layui-form" action="" style="float:left; margin-left: 8%; margin-top: 3%;">
            <!-- 输入框内容 -->
            <div class="demoTable search-style">
                驳回理由 / 通过课表数据处理：
                <div class="layui-inline">
                    <textArea style="height: 80px;width: 200px;resize: none;" id="bh_msg"></textArea>
                    <!-- <input class="layui-input" name="id" id="searchByPhone" autocomplete="off"> -->
                </div>
                <a class="layui-btn2 layui-btn" lay-submit lay-filter="formDemo">驳回</a>
                <a class="layui-btn2 layui-btn" lay-submit lay-filter="formDemo1">通过</a>
                <button type="button" class="layui-btn layui-btn-primary" onclick="javascript:window.history.go(-1);">
                    返回
                </button>
            </div>
        </form>
    </div>



</body>
<script src="../../layui/layui.js" charset="utf-8"></script>
<script type="text/javascript">

    /**
    * 获取query参数后面的属性
    * @param {String} name 需要获取的参数
    */
    var gtGetQueryString = function (name) {
        var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i')
        var url = window.location.href
        var search = url.substring(url.lastIndexOf('?') + 1)
        var r = search.match(reg)
        if (r != null) return decodeURI(r[2])
        return null
        window.gtGetQueryString = gtGetQueryString;
    };

    // layui.use
    layui.use(['dropdown', 'util', 'layer', 'table'], function () {
        var dropdown = layui.dropdown
            , util = layui.util
            , layer = layui.layer
            , table = layui.table
            , $ = layui.$
            , form = layui.form
            , element = layui.element;

        var uid = gtGetQueryString("uid"); // 获取 uid
        console.log(uid)

        var runner = {};
        $.ajax({
            type: 'post',
            url: '/api/READ/api/my/runner-detail/list/' + uid,
            async: false,
            headers: {
                token: localStorage.token
            },
            success: function (res) {
                // console.log(res.data)
                runner = res.data;
            }
        });
        var msg1 = document.getElementById("bh_msg");
        msg1.value = runner.msg;
        // console.log(runner)
        var url1 = runner.sfzFaceUrl;
        var url2 = runner.sfzReverseUrl;
        var url3 = runner.sourceUrl;
        var img = document.getElementById("img");
        img.setAttribute("src", url1);

        var img1 = document.getElementById("img1");
        img1.setAttribute("src", url2);

        var img2 = document.getElementById("img2");
        img2.setAttribute("src", url3);


        //监听提交
        form.on('submit(formDemo)', function (data) {

            var msg = document.getElementById("bh_msg");
            var userTypeDto = {
                uid: uid,
                msg: msg.value,
            }

            $.ajax({
                url: "/api/READ/api/my/runner-detail/apply/fail",
                type: "POST",
                traditional: true,//这使json格式的字符不会被转码
                contentType: 'application/json; charset=UTF-8',
                datatype: "json",
                headers: {
                    token: localStorage.token
                },
                data: JSON.stringify(userTypeDto),
                success: function (res) {
                    if (res.code === '200') {
                        layer.msg(res.msg);

                    } else {
                        layer.alert(res.msg, {
                            title: '提示'
                        });
                        return false;
                    }
                }
            })
            return false;
        });

        //监听提交
        form.on('submit(formDemo1)', function (data) {
            var msg = document.getElementById("bh_msg");
            var mymsg = msg.value.replace(/\n/g, "");
            console.log(msg.value)
            console.log(mymsg)
            
            var userTypeDto = {
                uid: uid,
                sourceHandle: mymsg,
            }

            $.ajax({
                url: "/api/READ/api/my/runner-detail/apply/ok",
                type: "POST",
                traditional: true,//这使json格式的字符不会被转码
                contentType: 'application/json; charset=UTF-8',
                datatype: "json",
                headers: {
                    token: localStorage.token
                },
                data: JSON.stringify(userTypeDto),
                success: function (res) {
                    if (res.code === '200') {
                        layer.msg(res.msg);

                    } else {
                        layer.alert(res.msg, {
                            title: '提示'
                        });
                        return false;
                    }
                }
            })
            console.log("点击通过")
            return false;
        });



        //初演示
        dropdown.render({
            elem: '.demo1'
            , data: [{
                title: name
                , id: 100

            }]
            , click: function (obj) {
                layer.tips('点击了：' + obj.title, this.elem, { tips: [1, '#5FB878'] })
            }
        });
    });
</script>

</html>